from multiprocessing import Process
from multiprocessing import Queue
from time import sleep


def produce(q):
    n=1
    while True:
        q.put(n)
        print('放入{}'.format(n))
        n=n+1
        sleep(1)
    pass


def costumer(q):
    while True:
        n=q.get()
        print('取出{}'.format(n))
        sleep(1)
    pass


if __name__ == '__main__':
    q = Queue(3)
    p1 = Process(target=produce, args=(q,))
    p2 = Process(target=costumer, args=(q,))

    p1.start()
    p2.start()

